home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / bbs / cit_src_7H21.lha / syscfg.c < prev    next >
C/C++ Source or Header  |  1997-07-27  |  25KB  |  752 lines

  1. /************************************************************************/
  2. /*                              syscfg.c                                */
  3. /*      configuration program for Citadel bulletin board system.  This  */
  4. /* file contains the system dependent code!                             */
  5. /************************************************************************/
  6. #define SYSTEM_DEPENDENT
  7. #define CONFIGURE
  8. #include "ctdl.h"
  9. #include "c68door.h"
  10. #include "stdarg.h"
  11. #include "dos.h"
  12. #include "fcntl.h"
  13. /************************************************************************/
  14. /*                              History                                 */
  15. /*                                                                      */
  16. /* 89Oct17 HAW  Amiga.                                                  */
  17. /* 89Jan15 HAW  Major release update: colors, etc....                   */
  18. /* 87Jan19 HAW  Created.                                                */
  19. /************************************************************************/
  20. /************************************************************************/
  21. /*                              Contents                                */
  22. /*                                                                      */
  23. /* #    dirExists()             check to see if directory exists        */
  24. /* #    doCommon()              handles common stuff                    */
  25. /*      GetDoorData()           reads in some piece of the door data    */
  26. /*      initSysSpec()           initialization for system dependencies  */
  27. /*      NextNonWhite()          finds next piece of non-whitespace      */
  28. /*      NextWhite()             finds next piece of white space         */
  29. /*      StoreDoor()             manages the reading a door              */
  30. /*      SysDepIntegrity()       makes necessary checks for integrity    */
  31. /*      sysSpecs()              System-dependent code for configure     */
  32. /*                                                                      */
  33. /*              # means local for this implementation                   */
  34. /************************************************************************/
  35. /************************************************************************/
  36. /*              Statics                                                 */
  37. /************************************************************************/
  38.  
  39. char onConsole=TRUE, remoteSysop=TRUE; /* dummies */
  40.  
  41.  
  42. static int  necessary[MAX_NEEDED]   =
  43.   {
  44.   0, 0, 0, 0, 0, 0, 0, 0,   /* currently 16 fields */
  45.   0, 0, 0, 0, 0, 0, 0, 0,
  46.   };
  47. static char curDir[80];
  48. void *DoorName(DoorData *d, DoorData *s);
  49. static SListBase DoorList  =
  50.   {
  51.   NULL, DoorName, NULL, free, NULL
  52.  
  53.   };
  54. FILE *doorfl;
  55. void totalBytes(long *size, FILE *fd);
  56. /************************************************************************/
  57. /*                External variable declarations in CONFG.C             */
  58. /************************************************************************/
  59. /***** THESE ARE REQUIRED DEFINITIONS! ******/
  60. char *R_W_ANY     = "r+";
  61. char *W_R_ANY     = "w+";
  62. char *READ_ANY    = "r+";
  63. char *READ_TEXT   = "r";
  64. char *WRITE_ANY   = "w";
  65. char *WRITE_TEXT  = "w";
  66. /*****  done  *****/
  67. extern CONFIG cfg;       /* The configuration variable           */
  68. extern MessageBuffer   msgBuf;
  69. extern rTable *roomTab;
  70. void WrtDoor(DoorData *d);
  71. /************************************************************************/
  72. /*      dirExists() check to see if the directory exists                */
  73. /************************************************************************/
  74. void dirExists(char *theDir)
  75.   {
  76.   char cx;
  77.   extern char FirstInit, ReInit;
  78.   strCpy(msgBuf.mbtext, theDir);
  79.   /* if (strLen(theDir) == 0) return ; */
  80.   if (msgBuf.mbtext[strLen(msgBuf.mbtext)-1] == '/')
  81.   msgBuf.mbtext[strLen(msgBuf.mbtext)-1] = '\0';
  82.   #ifdef READY
  83.   if (doch(msgBuf.mbtext) == EOF)
  84.     {
  85.     sPrintf(msgBuf.mbtext, "%s is not a directory!", theDir);
  86.     illegal(msgBuf.mbtext);
  87.  
  88.     }
  89.   #else
  90.   if (chdir(msgBuf.mbtext) == 0)
  91.     {
  92.     chdir(curDir);
  93.     return;
  94.  
  95.     }
  96.   if (access(msgBuf.mbtext, 0) == 0)
  97.     {
  98.     sPrintf(msgBuf.mbtext, "%s is not a directory!", theDir);
  99.     illegal(msgBuf.mbtext);
  100.  
  101.     }
  102.   printf("\nThe directory '%s' doesn't exist.  Create it? ",
  103.   msgBuf.mbtext);
  104.   if (FirstInit)  printf("Y\n ");
  105.   cx = simpleGetch();
  106.   if (ReInit || FirstInit || toUpper(cx) == 'Y')
  107.   if (mkdir(msgBuf.mbtext) != 0)  illegal("Couldn't make directory!");
  108.   printf("Finished calling mkdir\n");
  109.   #endif
  110.   #ifdef READY
  111.   else
  112.     {
  113.     printf("\nThe directory '%s' doesn't exist.  Create it? ",
  114.     msgBuf.mbtext);
  115.     if (FirstInit)
  116.     printf("Y\n ");
  117.     if (ReInit || FirstInit || toUpper(simpleGetch()) == 'Y')
  118.     if (mkdir(msgBuf.mbtext) == BAD_DIR)
  119.     illegal("Couldn't make directory!");
  120.  
  121.     }
  122.   #endif
  123.   #ifdef READY
  124.   doch(curDir);
  125.   #endif
  126.  
  127.   }
  128. /************************************************************************/
  129. /*      sysSpecs()  system specific configure stuff                     */
  130. /************************************************************************/
  131. int sysSpecs(char *line, int offset, char *status, FILE *fd)
  132.   {
  133.   char var[90], string[90];
  134.   int  arg;
  135.   *status = TRUE;
  136.   if (sscanf(line, "%s %s ", var, string))
  137.     {
  138.     arg = ( string[0] == '\"' ) ?   0  : atoi(string);
  139.     if (strCmpU(var, "#HELPAREA"  )    == SAMESTRING)
  140.       {
  141.       doAreaCommon(var, line, &cfg.homeArea, HELP);
  142.       }
  143.     else if (strCmpU(var, "#QWKWORKAREA" ) == SAMESTRING)
  144.       {
  145.       doAreaCommon(var, line, &cfg.QwkWorkArea,QWK1);
  146.       }
  147.     else if (strCmpU(var, "#BIOAREA" ) == SAMESTRING)
  148.       {
  149.       doAreaCommon(var, line, &cfg.bioArea,BIO_AREA);
  150.       }
  151.     else if (strCmpU(var, "#QWKLOCATION" ) == SAMESTRING)
  152.       {
  153.       readString(line, &cfg.QwkLocation.saDirname[0], FALSE);
  154.       necessary[QWK1]++;
  155.       }
  156.     else if (strCmpU(var, "#QWKFILEAREA" ) == SAMESTRING)
  157.       {
  158.       doAreaCommon(var, line, &cfg.QwkFileArea,QWK2);
  159.       }
  160.     else if (strCmpU(var, "#QWKNAME" ) == SAMESTRING)
  161.       {
  162.       readString(line, (char *)&cfg.QwkName, FALSE);
  163.       necessary[QWK3]++;
  164.       }
  165.     else if (strCmpU(var, "#QWKMAXROOM" ) == SAMESTRING)
  166.       {
  167.       cfg.QwkMaxRooms = arg;
  168.       }
  169.     else if (strCmpU(var, "#QWKMAXPACKET" ) == SAMESTRING)
  170.       {
  171.       cfg.QwkMaxPacket = arg;
  172.       }
  173.     else if (strCmpU(var, "#door"  )    == SAMESTRING)
  174.       {
  175.       StoreDoor(line, fd);
  176.  
  177.       }
  178.     else if (strCmpU(var, "#LOGAREA"  )    == SAMESTRING)
  179.       {
  180.       doAreaCommon(var, line, &cfg.logArea, LOG);
  181.  
  182.       }
  183.     else if (strCmpU(var, "#ROOMAREA"  )    == SAMESTRING)
  184.       {
  185.       doAreaCommon(var, line, &cfg.roomArea, ROOM);
  186.  
  187.       }
  188.     else if (strCmpU(var, "#MSGAREA"  )    == SAMESTRING)
  189.       {
  190.       doAreaCommon(var, line, &cfg.msgArea, MSG);
  191.  
  192.       }
  193.     else if (strCmpU(var, "#MSG2AREA" )    == SAMESTRING)
  194.       {
  195.       doAreaCommon(var, line, &cfg.msg2Area, MSG2);
  196.  
  197.       }
  198.     else if (strCmpU(var, "#NETAREA"  )    == SAMESTRING)
  199.       {
  200.       doAreaCommon(var, line, &cfg.netArea, NET_STUFF);
  201.  
  202.       }
  203.     else if (strCmpU(var, "#DOMAINAREA"  )    == SAMESTRING)
  204.       {
  205.       doAreaCommon(var, line, &cfg.domainArea, DOMAIN_STUFF);
  206.  
  207.       }
  208.     else if (strCmpU(var, "#AUDITAREA"  )    == SAMESTRING)
  209.       {
  210.       doAreaCommon(var, line, &cfg.auditArea, CALL);
  211.       cfg.Audit = 1;
  212.  
  213.       }
  214.     else if (strCmpU(var, "#HOLDAREA"  )    == SAMESTRING)
  215.       {
  216.       doAreaCommon(var, line, &cfg.holdArea, HOLD);
  217.       cfg.BoolFlags.HoldOnLost = TRUE;
  218.  
  219.       }
  220.     else if (strCmpU(var, "#FLOORAREA" )    == SAMESTRING)
  221.       {
  222.       doAreaCommon(var, line, &cfg.floorArea, FLOORA);
  223.  
  224.       }
  225.     else if (strCmpU(var, "#NET_RECEPT_AREA")   == SAMESTRING)
  226.       {
  227.       anyArea(var, line, cfg.receptArea.naDirname);
  228.  
  229.       }
  230.     else if (strCmpU(var, "#EDITOR") == SAMESTRING)
  231.       {
  232.       cfg.BoolFlags.SysopEditor = TRUE;
  233.       readString(line, cfg.DepData.Editor, FALSE);
  234.  
  235.       }
  236.     else if (strCmpU(var, "#EDIT-AREA") == SAMESTRING)
  237.       {
  238.       readString(line, cfg.DepData.EditArea, FALSE);
  239.  
  240.       }
  241.     else if (strCmpU(var, "#REINIT") == SAMESTRING)
  242.       {
  243.       readString(line, cfg.DepData.HiSpeedInit, TRUE);
  244.       if (strLen(cfg.DepData.HiSpeedInit) >=
  245.       sizeof cfg.DepData.HiSpeedInit)
  246.       illegal("The #REINIT parameter is too long.  29 is the max.");
  247.  
  248.       }
  249.     else if (strCmpU(var, "#LOCK-PORT") == SAMESTRING)
  250.       {
  251.       if (arg < 0 || arg > 8)
  252.       illegal("Bad value for #LOCK-PORT: 0-8 valid only.");
  253.       cfg.DepData.LockPort = arg;
  254.  
  255.       }
  256.     else if (strCmpU(var, "#CLOCK"   ) == SAMESTRING)
  257.       {
  258.       cfg.DepData.Clock &= SER_7WIRE;  /* save serial  7 wire flag */
  259.       if (     strCmpU(string, "none"  ) == SAMESTRING)
  260.       cfg.DepData.Clock |= NO_CLOCK;
  261.       else if (strCmpU(string, "inuse" ) == SAMESTRING)
  262.       cfg.DepData.Clock |= BUSY_CLOCK;
  263.       else if (strCmpU(string, "always") == SAMESTRING)
  264.       cfg.DepData.Clock |= ALWAYS_CLOCK;
  265.       else illegal("Didn't understand #CLOCK value.");
  266.  
  267.       }
  268.     else if (strCmpU(var, "#modemSetup"   ) == SAMESTRING)
  269.       {
  270.       readString(line, cfg.DepData.ModemSetup, TRUE);
  271.       strCat(cfg.DepData.ModemSetup, "\r");
  272.  
  273.       }
  274.     else if (strCmpU(var, "#SCREENWIDTH") == SAMESTRING)
  275.       {
  276.       if (arg < 640 || arg > 740)
  277.       illegal("The #SCREENWIDTH parameter is not between 640 and 740.");
  278.       cfg.DepData.ScreenWidth = arg;
  279.  
  280.       }
  281.     else if (strCmpU(var, "#SCREENHEIGHT") == SAMESTRING)
  282.       {
  283.       if (arg < 100 || (arg > 300 && arg < 400) || arg > 500)
  284.       illegal("The #SCREENHEIGHT parameter is not valid.");
  285.       cfg.DepData.ScreenHeight = arg;
  286.  
  287.       }
  288.     else if (strCmpU(var, "#SCREENCOLOR0") == SAMESTRING)
  289.       {
  290.       cfg.DepData.Color0 = arg;
  291.  
  292.       }
  293.     else if (strCmpU(var, "#SCREENCOLOR1") == SAMESTRING)
  294.       {
  295.       cfg.DepData.Color1 = arg;
  296.  
  297.       }
  298.     else if (strCmpU(var, "#DISABLEECHO") == SAMESTRING)
  299.       {
  300.       cfg.DepData.StartUpEcho = FALSE;
  301.  
  302.       }
  303.     else if (strCmpU(var, "#DIRECTTOCHIP") == SAMESTRING)
  304.       {
  305.       cfg.DepData.DirectToChip = TRUE;
  306.  
  307.       }
  308.     else if (strCmpU(var, "#WBENCHWINDOW") == SAMESTRING)
  309.       {
  310.       cfg.DepData.ScreenDepth = TRUE;
  311.  
  312.       }
  313.     else if (strCmpU(var, "#SERIALDEVICE") == SAMESTRING)
  314.       {
  315.       readString(line, cfg.DepData.DevName, FALSE);
  316.  
  317.       }
  318.     else if (strCmpU(var, "#UNITNUMBER") == SAMESTRING)
  319.       {
  320.       cfg.DepData.UnitNumber = arg;
  321.  
  322.       }
  323.     else if (strCmpU(var, "#SERIAL_7WIRE") == SAMESTRING)
  324.       {
  325.       cfg.DepData.Clock |= SER_7WIRE;
  326.  
  327.       }
  328.     else *status = FALSE;
  329.  
  330.     }
  331.   return offset;
  332.  
  333.   }
  334. /************************************************************************/
  335. /*      doAreaCommon() handles common stuff                             */
  336. /************************************************************************/
  337. void doAreaCommon(char *var, char *line, SYS_AREA *area, int which)
  338.   {
  339.   char *c;
  340.   anyArea(var, line, area->saDirname);
  341.   /**
  342.     make sure the directory name has a trailing slash or colon
  343.   **/
  344.   c = area->saDirname;
  345.   c += strlen(c) - 1;  /* get pointer to last character */
  346.   if( *c != ':' && *c != '/' )
  347.     {
  348.     c[1] = '/';   /* add a trailing slash */
  349.     c[2] = '\0';
  350.     };
  351.   necessary[which]++;
  352.  
  353.   }
  354. /************************************************************************/
  355. /*      anyArea() handles common stuff                                  */
  356. /************************************************************************/
  357. void anyArea(char *var, char *line, char *target)
  358.   {
  359.   readString(line, target, FALSE);
  360.  
  361.   }
  362. /************************************************************************/
  363. /*      initSysSpec() initialization for system dependencies            */
  364. /************************************************************************/
  365. void initSysSpec()
  366.   {
  367.   getcwd(curDir, sizeof curDir);
  368.   cfg.DepData.Editor[0]      =      0;
  369.   cfg.DepData.EditArea[0]    =      0;
  370.   cfg.DepData.HiSpeedInit[0] =      0;
  371.   cfg.DepData.LockPort       =     -1;
  372.   cfg.DepData.Clock          = ALWAYS_CLOCK;
  373.   cfg.DepData.ScreenWidth    =    640;
  374.   cfg.DepData.ScreenHeight   =    200;
  375.   cfg.DepData.ScreenDepth    =      0; /*WBENCHWINDOW*/
  376.   cfg.DepData.Color0         = 0x0018;
  377.   cfg.DepData.Color1         = 0x0FFF;
  378.   cfg.DepData.StartUpEcho    =      1;
  379.   cfg.DepData.DirectToChip   =      0;
  380.   cfg.DepData.UnitNumber     =      0;
  381.   cfg.QwkMaxRooms            =     20;
  382.   cfg.QwkMaxPacket           =    200;
  383.   strcpy(cfg.DepData.DevName,"serial.device");
  384.  
  385.   }
  386. #define WhiteSpace(x)   ((x) == ' ' || (x) == '\t' || (x) == '\n')
  387. /*
  388. * #door <entrycode> <program name> <location> <who> <where> <how long>
  389. * <description>
  390. * <parameter list>
  391. */
  392. /************************************************************************/
  393. /*      StoreDoor() manages the reading and interpretation of a door    */
  394. /************************************************************************/
  395. void StoreDoor(char *line, FILE *fd)
  396.   {
  397.   char     *s;
  398.   DoorData *DoorInfo;
  399.   char     l2[100];
  400.   char     temp[15];
  401.   DoorInfo = (DoorData *) GetDynamic(sizeof *DoorInfo);
  402.   zero_struct(*DoorInfo);
  403.   line += 5;  /* now we point at the space before the entry code. */
  404.   /* get entrycode */
  405.   if ((line = GetDoorData(line, DoorInfo->entrycode, 6)) == NULL)
  406.     illegal("Problem with parsing the entry code for a door!");
  407.   /* get program name */
  408.   if ((line = GetDoorData(line, DoorInfo->program, 14)) == NULL)
  409.     illegal("Problem with parsing the program for a door!");
  410.   /* get door preferred location */
  411.   if ((line = GetDoorData(line, DoorInfo->location, 50)) == NULL)
  412.     illegal("Problem with parsing the location of a door! (d1)");
  413.   /* get door privilege */
  414.   if ((line = GetDoorData(line, temp, 15)) == NULL)
  415.     illegal("Problem with parsing the location of a door (d2)!");
  416.   if (strCmpU(temp, "anyone") == SAMESTRING)
  417.     DoorInfo->flags |= DOOR_ANYONE;
  418.   else if (strCmpU(temp, "aide") == SAMESTRING)
  419.     DoorInfo->flags |= DOOR_AIDE;
  420.   else if (strCmpU(temp, "sysop") == SAMESTRING)
  421.     DoorInfo->flags |= DOOR_SYSOP;
  422.   else if (strCmpU(temp, "autodoor") == SAMESTRING)
  423.     DoorInfo->flags |= DOOR_AUTO;
  424.   else if (strCmpU(temp, "newusers") == SAMESTRING)
  425.     DoorInfo->flags |= DOOR_NEWUSER;
  426.   else illegal("Could not identify who is allowed to use this door!");
  427.   /* get MODEM/CONSOLE/EITHER flag */
  428.   if ((line = GetDoorData(line, temp, 15)) == NULL)
  429.     illegal("Problem with parsing the 'where' field!");
  430.   if (strCmpU(temp, "anywhere") == SAMESTRING)
  431.     {
  432.     DoorInfo->flags |= DOOR_CON;
  433.     DoorInfo->flags |= DOOR_MODEM;
  434.  
  435.     }
  436.   else if (strCmpU(temp, "console") == SAMESTRING)
  437.   DoorInfo->flags |= DOOR_CON;
  438.   else if (strCmpU(temp, "modem") == SAMESTRING)
  439.   DoorInfo->flags |= DOOR_MODEM;
  440.   else illegal("Could not identify the 'where' value!");
  441.   /* get time limit of door */
  442.   if ((line = GetDoorData(line, temp, 15)) == NULL)
  443.   illegal("Problem with parsing the 'time' field!");
  444.   if (strCmpU(temp, "unlimited") == SAMESTRING)
  445.   DoorInfo->TimeLimit = -1;
  446.   else
  447.   DoorInfo->TimeLimit = atoi(temp);
  448.   /* Now get optional room to tie this door to */
  449.   if ((s = strrchr(line, '\n')) != NULL) *s = 0;
  450.   strCpy(DoorInfo->RoomName, line);
  451.   /* get description of door */
  452.   if (fgets(l2, 100, fd) == NULL) illegal("Unexpected EOF in door handling!");
  453.   if ((s = strrchr(l2, '\n')) != NULL) *s = 0;
  454.   if (strLen(l2) >= 80)  illegal("Description too long!");
  455.   strCpy(DoorInfo->description, l2);
  456.   /* get parameters of door */
  457.   if (fgets(l2, 100, fd) == NULL) illegal("Unexpected EOF in door handling!");
  458.   if ((s = strrchr(l2, '\n')) != NULL) *s = 0;
  459.   if (strLen(l2) >= 99) illegal("Parameters too long!");
  460.   strCpy(DoorInfo->parameters, l2);
  461.   AddData(&DoorList, DoorInfo, NULL, FALSE);
  462.  
  463.   }
  464. /************************************************************************/
  465. /*      GetDoorData() reads in some piece of the door data.             */
  466. /************************************************************************/
  467. char *GetDoorData(char *line, char *field, int size)
  468.   {
  469.   char *s;
  470.   if ((line = NextNonWhite(line)) == NULL)
  471.   return NULL;
  472.   /* Now skip over field so we may zero out & copy */
  473.   if ((s = NextWhite(line)) == NULL)
  474.   return NULL;
  475.   *s = 0;             /* zero whitespace */
  476.   if (strLen(line) >= size)
  477.     {
  478.     printf("Value '%s' too long for door's data field.\n", line);
  479.     return NULL;
  480.  
  481.     }
  482.   strCpy(field, line);
  483.   return s + 1;
  484.  
  485.   }
  486. /************************************************************************/
  487. /*      NextWhite() Finds next piece of white space on the line.        */
  488. /************************************************************************/
  489. char *NextWhite(char *line)
  490.   {
  491.   char *s;
  492.   for (s = line; !WhiteSpace(*s) && *s; s++)
  493.   ;
  494.   if (!(*s)) return NULL;
  495.   return s;
  496.  
  497.   }
  498. /************************************************************************/
  499. /*      NextNonWhite() Finds next piece of non-whitespace.              */
  500. /************************************************************************/
  501. char *NextNonWhite(char *line)
  502.   {
  503.   char *s;
  504.   for (s = line; WhiteSpace(*s) && *s; s++)
  505.   ;
  506.   if (!(*s)) return NULL;
  507.   return s;
  508.  
  509.   }
  510. FILE *upfd;
  511. /************************************************************************/
  512. /*      WriteDoors() writes out the list of doors.                      */
  513. /************************************************************************/
  514. void WriteDoors()
  515.   {
  516.   SYS_FILE DoorFile;
  517.   makeSysName(DoorFile, DOOR_DATA, &cfg.roomArea);
  518.   if ((doorfl = fopen(DoorFile, WRITE_ANY)) == NULL)
  519.     {
  520.     sPrintf(msgBuf.mbtext, "Could not create %s.", DoorFile);
  521.     illegal(msgBuf.mbtext);
  522.  
  523.     }
  524.   RunList(&DoorList, WrtDoor);
  525.  
  526.   }
  527. /************************************************************************/
  528. /*      WrtDoor() writes out a single door.                             */
  529. /************************************************************************/
  530. void WrtDoor(DoorData *d)
  531.   {
  532.   if( fwrite(d, sizeof *d, 1, doorfl) != 1 )
  533.     {
  534.     printf("Write error: Door data file\n");
  535.     };
  536.   }
  537. /************************************************************************/
  538. /*      SysDepIntegrity() makes necessary checks for integrity          */
  539. /************************************************************************/
  540. static char Check_Flag(int flag, int orflag, char *message);
  541. static char Check_Flag(int flag, int orflag, char *message)
  542.   {
  543.   if( !flag )
  544.     {
  545.     printf(" --%s parameters were not completely defined\n",message);
  546.     orflag = TRUE;
  547.     };
  548.   return ( char )orflag;
  549.   }
  550.  
  551. char SysDepIntegrity(int *offset)
  552.   {
  553.   char bad;
  554.   bad = Check_Flag(necessary[HELP],    FALSE, "Help");
  555.   bad = Check_Flag(necessary[MSG],       bad, "Message");
  556.   bad = Check_Flag(necessary[FLOORA],    bad, "Floor");
  557.   bad = Check_Flag(necessary[LOG],       bad, "User Log");
  558.   bad = Check_Flag(necessary[ROOM],      bad, "Room");
  559.   bad = Check_Flag(necessary[ BIO_AREA], bad, "Biography Area");
  560.  
  561.   if( necessary[QWK1] || necessary[QWK2] || necessary[QWK3] )
  562.     {
  563.     bad = Check_Flag(necessary[QWK1],   bad, "QWK Location");
  564.     bad = Check_Flag(necessary[QWK2],   bad, "QWK packet");
  565.     bad = Check_Flag(necessary[QWK3],   bad, "QWK file");
  566.     if( !bad )cfg.BoolFlags.QwkMail = 1;
  567.     }
  568.   if( cfg.Audit !=0 )bad = Check_Flag(necessary[CALL], bad, "Audit");
  569.   if( cfg.BoolFlags.mirror )
  570.     bad = Check_Flag(necessary[MSG2],   bad, "Mirror Message");
  571.   if( cfg.BoolFlags.netParticipant )
  572.     {
  573.     bad = Check_Flag(necessary[NET_STUFF],    bad, "Networking");
  574.     bad = Check_Flag(necessary[DOMAIN_STUFF], bad, "Domain");
  575.     };
  576.   if( bad )  illegal("See the above error messages.");
  577.   dirExists(cfg.homeArea.saDirname);
  578.   dirExists(cfg.logArea.saDirname);
  579.   dirExists(cfg.roomArea.saDirname);
  580.   dirExists(cfg.msgArea.saDirname);
  581.   dirExists(cfg.floorArea.saDirname);
  582.   dirExists(cfg.bioArea.saDirname);
  583.   if (cfg.BoolFlags.mirror)
  584.     dirExists(cfg.msg2Area.saDirname);
  585.   if (cfg.BoolFlags.netParticipant)
  586.     {
  587.     dirExists(cfg.netArea.saDirname);
  588.     dirExists(cfg.receptArea.naDirname);
  589.     dirExists(cfg.domainArea.saDirname);
  590.     };
  591.   if (cfg.Audit)
  592.     dirExists(cfg.auditArea.saDirname);
  593.   if (necessary[HOLD])
  594.     dirExists(cfg.holdArea.saDirname);
  595.   if( necessary[QWK1] || necessary[QWK3] )
  596.     {
  597.     dirExists(cfg.QwkWorkArea.saDirname);
  598.     dirExists(cfg.QwkFileArea.saDirname);
  599.     };
  600.   WriteDoors();
  601.   return TRUE;
  602.  
  603.   }
  604. int Dcount;
  605. /************************************************************************/
  606. /*      FindDoorSlot() looks for the specified door for autodoor stuff  */
  607. /************************************************************************/
  608. int FindDoorSlot(char *name)
  609.   {
  610.   int *c;
  611.   DoorData temp;
  612.   Dcount = 0;
  613.   strCpy(temp.entrycode, name);
  614.   if ((c = (int *) SearchList(&DoorList, &temp)) != NULL)
  615.   return *c;
  616.  
  617.   }
  618. /************************************************************************/
  619. /*      DoorName() check to see if this door is here.                                   */
  620. /************************************************************************/
  621. void *DoorName(DoorData *d, DoorData *s)
  622.   {
  623.   if (strCmpU(d->entrycode, s->entrycode) == SAMESTRING)
  624.   return &Dcount;
  625.   Dcount++;
  626.   return NULL;
  627.  
  628.   }
  629. /*************************************************************************/
  630. /*   simpleGetch() for AmigaDos version           */
  631. /*************************************************************************/
  632. int simpleGetch()
  633.   {
  634.   char inval;
  635.   do
  636.     {
  637.     scanf("%c",&inval);
  638.     inval = toupper(inval);
  639.  
  640.     }
  641.   while( (inval != 'Y') && (inval != 'N') );
  642.   return(inval);
  643.  
  644.   }
  645. /************************************************************************/
  646. /*              totalBytes() how many bytes in this here file?          */
  647. /************************************************************************/
  648. void totalBytes(long *size, FILE *fd)
  649.   {
  650.   *size = lseek(fileno(fd),-1l,2)+1;
  651.  
  652.   }
  653. char bigbuffer[7500];
  654. /************************************************************************/
  655. /*              mPrintf()  can you say kludge?                          */
  656. /************************************************************************/
  657. int mPrintf(char *format, ...)
  658.   {
  659.   va_list argptr;
  660.   va_start(argptr, format);
  661.   vsprintf(bigbuffer, format, argptr);
  662.   va_end(argptr);
  663.   printf("%s",bigbuffer);
  664.   return 0;
  665.   }
  666. /************************************************************************/
  667. /*      sPrintf() write from format+args to supplied string             */
  668. /************************************************************************/
  669. int sPrintf(char *garp, const char *format, ...)
  670.   {
  671.   va_list argptr;
  672.   va_start(argptr, format);
  673.   vsprintf(garp, format, argptr);
  674.   va_end(argptr);
  675.   return 0;
  676.   }
  677. char sysArgs(char *str)
  678.   {
  679.   return FALSE;
  680.  
  681.   }
  682. void *EatDirEntry(char *line);
  683. char DirDeleted = FALSE;
  684. SListBase DirRooms =
  685.   {
  686.   NULL, NULL, NULL, NULL, EatDirEntry
  687.  
  688.   };
  689. FILE *Dirs;
  690. /************************************************************************/
  691. /*      FinalSystemCheck() final system dependent checks                */
  692. /************************************************************************/
  693. int FinalSystemCheck(char OnlyParams)
  694.   {
  695.   SYS_FILE fn;
  696.   void WriteDir();
  697.   /* Check for excess entries in ctdldir.sys */
  698.   makeSysName(fn, "ctdldir.sys", &cfg.roomArea);
  699.   MakeList(&DirRooms, fn, NULL);
  700.   if (DirDeleted)
  701.     {
  702.     if ((Dirs = fopen(fn, WRITE_TEXT)) != NULL)
  703.       {
  704.       RunList(&DirRooms, WriteDir);
  705.       fclose(Dirs);
  706.  
  707.       }
  708.  
  709.     }
  710.   return TRUE;
  711.  
  712.   }
  713. void WriteDir(char *l)
  714.   {
  715.   fprintf(Dirs, "%s\n", l);
  716.  
  717.   }
  718. /************************************************************************/
  719. /*      EatDirEntry() validates an entry from ctdldir.sys               */
  720. /************************************************************************/
  721. void *EatDirEntry(char *line)
  722.   {
  723.   char *space;
  724.   int  room;
  725.   /* discard garbled entries */
  726.   if ((space = strchr(line, ' ')) == NULL)
  727.     {
  728.     DirDeleted = TRUE;
  729.     printf("Garbled entry -%s- deleted from ctdldir.sys.\n", line);
  730.     return NULL;
  731.  
  732.     }
  733.   room = atoi(line);
  734.   if (room >= MAXROOMS || room < 0)
  735.     {
  736.     DirDeleted = TRUE;
  737.     printf("Out of range entry -%s- deleted from ctdldir.sys.\n", line);
  738.     return NULL;
  739.  
  740.     }
  741.   if (roomTab[room].rtflags.INUSE && roomTab[room].rtflags.ISDIR)
  742.   return strdup(line);
  743.   DirDeleted = TRUE;
  744.   printf("Excess entry -%s- deleted from ctdldir.sys.\n", line);
  745.   return NULL;
  746.  
  747.   }
  748. /*  Stub routine for debug purposes */
  749. void splitF(FILE *fd, char *x,...)  { }
  750. void Do_Stack_Check(void);
  751. void Do_Stack_Check(void) { }
  752.